package com.smart.service.init;

import java.util.Date;

import org.springframework.stereotype.Service;

import com.smart.core.init.AbstractDataInitializeService;
import com.smart.core.init.InitServiceOrder;
import com.smart.model.Menu;

/**
 * 初始化根菜单
 * 
 * @author Xin.Sun
 *
 */
@Service
public class MenuInitService extends AbstractDataInitializeService{
	@Override
	public int getOrder() {
		return InitServiceOrder.INIT_ORDER_MENU;
	}

	@Override
	public void initData() throws Exception {
		logger.info("init menu data at {}", new Date());
		Menu obj = menuService.findOneBy("code", Menu.ROOT_MENU_CODE);
		if(obj==null){
			Menu menu = new Menu();
			menu.setCode(Menu.ROOT_MENU_CODE);
			menu.setName("根菜单");
			menu.setLevel(0);
			menuService.save(menu);
			
			Menu menu1 = new Menu();
			menu1.setCode("index");
			menu1.setName("首页");
			menu1.setParent(menu);
			menu1.setUrl("index");
			menu1.setAttr1("page1");
			menuService.save(menu1);
			
			Menu menu2 = new Menu();
			menu2.setCode("companyIntro");
			menu2.setName("企业概况");
			menu2.setAttr1("");
			menu2.setParent(menu);
			menu2.setUrl("family");
			menuService.save(menu2);
			
			Menu menu21 = new Menu();
			menu21.setCode("companyIntro");
			menu21.setName("公司简介");
			menu21.setAttr1("");
			menu21.setParent(menu2);
			menu21.setUrl("family");
			menuService.save(menu21);
			
			Menu menu22 = new Menu();
			menu22.setCode("companyIntro");
			menu22.setName("联系我们");
			menu22.setAttr1("");
			menu22.setParent(menu2);
			menu22.setUrl("family");
			menuService.save(menu22);
			
			Menu menu23 = new Menu();
			menu23.setCode("companyIntro");
			menu23.setName("法律声明");
			menu23.setAttr1("");
			menu23.setParent(menu2);
			menu23.setUrl("family");
			menuService.save(menu23);
			
			Menu menu24 = new Menu();
			menu24.setCode("companyIntro");
			menu24.setName("风险提示");
			menu24.setAttr1("");
			menu24.setParent(menu2);
			menu24.setUrl("family");
			menuService.save(menu24);
			
			Menu menu25 = new Menu();
			menu25.setCode("companyIntro");
			menu25.setName("隐私条款");
			menu25.setAttr1("");
			menu25.setParent(menu2);
			menu25.setUrl("family");
			menuService.save(menu25);
			
			
			Menu menu3 = new Menu();
			menu3.setCode("optionStudy");
			menu3.setName("期权课堂");
			menu3.setAttr1("page2");
			menu3.setParent(menu);
			menu3.setUrl("#page2");
			menuService.save(menu3);
			
			Menu menu4 = new Menu();
			menu4.setCode("stockMarket");
			menu4.setName("股票行情");
			menu4.setParent(menu);
			menu4.setUrl("malaixiya");
			menuService.save(menu4);
			
			Menu menu5 = new Menu();
			menu5.setCode("account");
			menu5.setName("账户充值");
			menu5.setParent(menu);
			menu5.setUrl("taiguo");
			menuService.save(menu5);
			
			Menu menu6 = new Menu();
			menu6.setCode("software");
			menu6.setName("软件下载");
			menu6.setParent(menu);
			menu6.setUrl("jianpuzhai");
			menuService.save(menu6);
		}
	}

}
